package hxy.scan.server.controller;


import hxy.scan.server.dao.model.SingleModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
public class SingleController {

    @Resource
    hxy.scan.server.dao.mapper.SingleMapper singleMapper;


    @PostMapping("/single-create")
    public int create(@RequestBody SingleModel singleEntity) {

        String name = singleEntity.getName();

        return singleMapper.insert(singleEntity);
    }


    @GetMapping("/single-list")
    public List<SingleModel> list() {
        List<SingleModel> singleModels = singleMapper.selectList(null);

        for (SingleModel singleModel : singleModels) {
            String name = singleModel.getName();
            if (name != null && name.equals("张三")) {
                log.info("有问题");
            }
            log.info(name);
        }


        return singleModels;
    }

}
